With more arid more applications operating on a terminal, available memory resources of the terminal become less and less, which may affect operation smoothness of the applications. Therefore, the memory resources of the terminal generally need to be optimized.
Conventionally, when optimizing the memory resources, the terminal arranges a plurality of created processes into one control group, known as Cgroup, and restricts a total resource value of memory resources that can be occupied by the processes in the control group through setting a resource threshold. For example, a process is an instance of a computer program that is being executed. When the terminal needs to add a newly created process into the control group and detects that the total resource value of the control group after adding the newly created process exceeds the resource threshold, a swap-out operation is performed. For example, the terminal transfers data corresponding to an idle process that is not used for a period of time in the control group to a storage device, allocates resources previously occupied by the data to the newly created process, and transfers the data from the storage device to the memory resources occupied by the control group when the idle process is needed again.